<html>
<head>
<title>duetopia - Documentation - OpenSearch</title>
</head>
<body>

<h1>duetopia</h1>

<h2>OpenSearch</h2>

<p>For any class in the data model you can generate an OpenSearch description. 

<p>For the basic DataSet and Series classes this is already supplied. Here we explain how it works and how to decorate your own <a href="custom_class.html">custom classes</a> so that they automatically provide an OpenSearch description.</p>

<ul>
<li><a href="http://www.opensearch.org/Home">http://www.opensearch.org/Home</a></li>
<li><a href="http://www.terradue.com/news/_news.asp?id=28"> - INSPIRE with OpenSearch overview</a></li>
<li><a href="http://www.terradue.com/news/_news.asp?id=107">OpenSearch strengths and weaknesses</a> regarding our use of the protocol in duetopia</li>
</ul>


<p>
We use Django to define the basic data model. Django provides a standard way to add metadata a class using the "Meta" class. See the "Meta options" section of the <a href="http://www.djangoproject.com/documentation/model-api/">Django model reference documentation</a>.</p>

<p>In duetopia we take the <b>same principle and use it for search. Each class has a Search meta class</b> from which the OpenSearch description is built.
This example looks at the Search class used for DataSets by default.

(see <tt>duetopia/register/models/data.py</tt> for the running code).</p>

<p>
Define a list of namespaces to use in the OpenSearch query. We make use of the "Geo" and "Time" extensions. We would expect a site with complex structured data to supply and define their own.

<pre>
        namespaces = {
            "geo" : "http://a9.com/-/opensearch/extensions/geo/1.0/",
            "time" : "http://a9.com/-/opensearch/extensions/time/1.0/",
            }
</pre>

<p>A list of search_terms provides a series of dictionary lookups - mapping the name of the property to the part of the OpenSearch query used to look for it and the appropriate database filters or constraints needed to run the search.</p>
<p>A simple example; 
<pre>
        search_terms = (
                { "name" : "title",
                  "type" : "django",
                  "filter" : "title__icontains",
                  "query" : "searchTerms?" },
</pre>

<p>
<b>name</b> - name of the key as it appears in the OpenSearch description
<br/>
<b>query</b> - the value in the OpenSearch description template
<br/>
<b>type</b> - where this metadata is stored, and thus should be queried from. For now either 'django' (in the core django model) or 'rdf' (in the rdf annotations). In future it may be possible to use this to "cascade" a search to another instance of duetopia. 
<br/>
<b>filter</b> - if this is a django query, then a database filter
 

                { "name" : "start",
                  "type" : "django",
                  "filter" : "start__gte",
                  "query" : "time:Start?" },
                
                { "name" : "end",
                  "type" : "django",
                  "filter" : "end__lt",
                  "query" : "time:End?" },

                { "name" : "geometry",
                  "type" : "geodjango",
                  "filter" : "extents__intersects",
                  "query" : "geo:box" },

                { "name" : "keyword",
                  "type" : "rdf",
                  "uri" : rdf.dc.subject.uri,
                  "query" : "searchTerms?" })


</pre>

<tt>duetopia/opensearch/decoration.py</tt>
</p>


</body>
</html>

